package com.oa.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.oa.dao.DepartmentDao;
import com.oa.entity.Department;
import com.oa.service.DepartmentService;

/**
 * @author FengMengHuo
 * 部门 服务类
 */
@Service("departmentService")
@Transactional
public class DepartmentServiceImpl implements DepartmentService {

	// 通过注解把 部门 dao 注入进来
	@Resource(name = "departmentDao")
	private DepartmentDao departmentDao;

	// 查询所有部门
	public List<Department> list() {
		return departmentDao.findAllEntity();
	}

	// 添加部门
	public boolean add(Department department) {
		return departmentDao.saveEntity(department);
	}

	// 删除部门
	public boolean delete(Department department) {
		return departmentDao.deleteEntity(department);
	}

	// 修改部门
	public boolean update(Department department) {
		return departmentDao.updateEntity(department);
	}

	// 根据ID 查询单个部门
	public Department getById(String unique_id) {
		return departmentDao.getEntity(unique_id);
	}

	// 查询第一个部门列表
	public List<Department> findTopList() {
		return departmentDao.findTopList();
	}

	// 查询子部们列表
	public List<Department> findChildren(String parentId) {
		return departmentDao.findChildren(parentId);
	}

}
